﻿// -------------------------------------------------------------------------
//    @FileName         :    NFPlayerStatus.h
//    @Author           :    gaoyi
//    @Date             :    23-11-17
//    @Email			:    445267987@qq.com
//    @Module           :    NFPlayerStatus
//
// -------------------------------------------------------------------------

#pragma once

#include "proto_need.nanopb.h"
#include "NFComm/NFCore/NFPlatform.h"

/**
 * \brief 负责玩家数据的生命周期管理
 */
class NFCacheStatus
{
public:
    NFCacheStatus();

    virtual ~NFCacheStatus();

    int CreateInit();
    int ResumeInit();

public:
    virtual int Tick();

public:
    virtual uint64_t StatusId() const = 0;

    virtual bool IsCanLogout();

    virtual int DoOnline();

    virtual bool IsCanDelete();

    virtual int DoLogout();

public:
    enCacheStatus GetPlayerStatus() const;

    void SetPlayerStatus(enCacheStatus status);

    bool IsDeadStatus() const
    {
        return m_cacheStatus == CACHE_STATUS_DELETE;
    }

    uint64_t GetCreateTime() const;

    void SetCreateTime(uint64_t createTime);

    uint64_t GetLastDiconnectTime() const;

    void SetLastDiconnectTime(uint64_t lastDiconnectTime);

    uint64_t GetLastLogoutTime() const;

    void SetLastLogoutTime(uint64_t lastLogoutTime);

    bool IsDisconnect() const;

    void SetIsDisconnect(bool isDisconnect);

    bool IsOnline() const;

    void SetIsOnline(bool isOnline);

protected:
    /**
     * @brief
     */
    enCacheStatus m_cacheStatus;
    uint64_t m_lastCreateTime;
    uint64_t m_lastDisconnectTime;
    uint64_t m_lastLogoutTime;
    bool m_isDisconnect;

protected:
    uint32_t m_timeMulti;
};
